
package com.eworking.eim.group;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.eworking.eim.user.EIMUser;

public class EIMGroup extends EIMUser {
    
    /** 群组拥有着者 */
    private String owner;
    
    /** 最后修改时间 */
    private long lastModifiedTime;
    
    /** 是否公共群组 */
    private boolean isPublic = false;
    
    /** 是否允许邀请 */
    private boolean allowInvites = false;
    
    /**  */
    private boolean membersOnly = false;
    
    protected List<String> members = new ArrayList<String>();
    
    private String description;
    
    public EIMGroup(String account) {
        super(account);
    }
    
    public String getOwner() {
        return owner;
    }
    
    public void setOwner(String owner) {
        this.owner = owner;
    }
    
    public long getLastModifiedTime() {
        return lastModifiedTime;
    }
    
    public void setLastModifiedTime(long lastModifiedTime) {
        this.lastModifiedTime = lastModifiedTime;
    }
    
    public boolean isPublic() {
        return isPublic;
    }
    
    public void setPublic(boolean isPublic) {
        this.isPublic = isPublic;
    }
    
    public boolean isAllowInvites() {
        return allowInvites;
    }
    
    public void setAllowInvites(boolean allowInvites) {
        this.allowInvites = allowInvites;
    }
    
    public boolean isMembersOnly() {
        return membersOnly;
    }
    
    public void setMembersOnly(boolean membersOnly) {
        this.membersOnly = membersOnly;
    }
    
    public synchronized void addMember(String paramString) {
        this.members.add(paramString);
    }
    
    public synchronized void removeMember(String paramString) {
        this.members.remove(paramString);
    }
    
    public synchronized List<String> getMembers() {
        return Collections.unmodifiableList(this.members);
    }
    
    public synchronized void setMembers(List<String> paramList) {
        this.members.addAll(paramList);
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public String getGroupId() {
        return this.account;
    }
    
    public void setGroupId(String account) {
        this.account = account;
    }
    
    public String getGroupName() {
        return this.nickname;
    }
    
    public void setGroupName(String groupName) {
        this.nickname = groupName;
    }
    
    public void copyGroup(EIMGroup group) {
        this.JID = group.JID;
        this.description = group.description;
        this.isPublic = group.isPublic;
        this.allowInvites = group.allowInvites;
        this.membersOnly = group.membersOnly;
        this.lastModifiedTime = System.currentTimeMillis();
        this.members.clear();
        this.members.addAll(group.getMembers());
        this.nickname = group.nickname;
        this.owner = group.owner;
        this.account = group.account;
    }
}
